package com.winit.need.util;

import com.winit.commons.util.DateUtil;
import org.springframework.util.StringUtils;

public class NeedUtil {

    public static String dealStatusTime(String old, String status) {
        if (StringUtils.isEmpty(status)) {
            return old;
        }
        if (StringUtils.isEmpty(old)) {
            return "," + status + "-" + DateUtil.getCurDateStr("yyyyMMddHHmmss") + ",";
        }

        if (old.contains("," + status + "-")) {
            return old.replaceAll("([\\S]*)(,)(" + status + "-)([0-9]*)(,)([\\s\\S]*)", "$1$2$3" + DateUtil.getCurDateStr("yyyyMMddHHmmss") + "$5$6");
        }
        return old + status + "-" + DateUtil.getCurDateStr("yyyyMMddHHmmss") + ",";
    }


//    public static void main(String[] args) {
//        System.out.println(NeedUtil.dealStatusTime("","d"));
//    }

}
